<!--数据库维护-->
<div class="row">
    <!-- 映射列表 -->
    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12" id="leftTree">
        <div class="widget flat radius-bordered">
            <div class="widget-header bg-sky theme">
                <span class="widget-caption">数据库维护</span>
            </div>
            <div class="widget-body no-padding">
                <div id="aceEditLoadHint" style="text-align: center">加载中...</div>
                <form id="aceEditParamForm" action="switchView.do?viewPath=common/aceEditor/aceEdit.html" method="post" target="aceEditIframe" class="hidden" accept-charset="utf-8">
                    <input type="hidden" name="sorceTreeViewUrl" value="${ctx}/preserve/database/databaseTablesTree.do"><#--左侧资源树视图路径-->
                    <input type="hidden" name="mode" value='${dbType}'><#--编辑器编程语言模式-->
                    <input type="hidden" name="theme" value='${theme}'><#--编辑器主题-->
                    <input type="hidden" name="callback" value='loadDatabaseTableCallback'><#--资源树加载成功后的回调函数-->
                    <input type="hidden" name="executeCallback" value='executeSql'><#--点击执行按钮时的回调函数的回调函数-->
                    <input type="hidden" name="saveCallback" value='saveSql'><#--点击保存时的的回调函数-->
                    <input type="hidden" name="params" value='${params}'><#--加载资源树时的参数-->
                    <input type="hidden" name="extendCompleteData" value='${extendCompleteData}'><#--扩展自动补全数据-->
                </form>
                <form id="downloadSqlForm" action="${ctx}/preserve/database/saveSql.do" method="post" target="downloadSqlIframe" style="display: none">
                    <input type="hidden" name="sql">
                </form>
                <iframe style="width: 100%; height: 91%;border:none;" name="aceEditIframe"/>
                <iframe name="downloadSqlIframe" style="display: none;"></iframe>
            </div>
        </div>
    </div>
</div>
<script>
//自动提交表单
setTimeout(function(){
    console.log($("#aceEditParamForm").size());
    $("#aceEditLoadHint").remove();
    $("#aceEditParamForm").submit();
},100)
function loadDatabaseTableCallback(result){
    console.log("数据库表加载结果回调:"+result);
}
//点击执行按钮时的回调函数的回调函数
function executeSql(sql,resultCallback){
    if(!sql){
        Notify('请输入sql', 'bottom-right', '500', 'danger', 'fa-edit', true);
        return false;
    }
    var url="${ctx}/preserve/database/execSql.do";
    var params={
        sql:sql
    }
    Notify('正在执行sql...', 'bottom-right', '500', 'success', 'fa-info', true);
    ajaxRequest(url, params, function (resultHtml) {
        resultCallback(resultHtml);
    },
    function (XMLHttpRequest, textStatus, errorThrown) {
        ajaxError(errorThrown);
    }, "GET", "HTML");
}
//点击保存时的的回调函数
function saveSql(sql){
    if(!sql){
        Notify('请输入sql', 'bottom-right', '500', 'danger', 'fa-edit', true);
        return false;
    }
    console.log("正在将sql另存为文件...");
    Notify('正在将sql另存为文件...', 'bottom-right', '500', 'success', 'fa-info', true);
    $("#downloadSqlForm").find("[name='sql']").val(encodeURIComponent(sql)).end().submit();
}
</script>


